<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>滴答办公系统-学科列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
<script src="media/js/jquery.min.js"></script>
	<script>
		function ChangeMajorPagesize(pagesize){
			// alert(pagesize)
			location.href="/Major_list?pageIndex=1&pagesize="+pagesize
		}
	</script>
</head>
<body>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>序号</td>
					<td>学科名称</td>
					<td>周数</td>
					<td>成立日期</td>
					<td>类型</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
				<tr th:id="|tr_${d.id}|" th:each="d:${majorutils.recods}">
					<td th:text="${d.id}">01</td>
					<td th:text="${d.majorName}">JAVAEE</td>
					<td th:text="${d.majorTime}">50</td>
					<td th:text="${d.majorDate}">2015-10-01</td>
					<td th:text="${d.tmajorType.majortype}">后台</td>
					<td><a class="layui-btn layui-btn-mini" th:href="|Major_toupdate/${d.id}|">编辑</a>
						<a class="layui-btn layui-btn-danger layui-btn-mini"
						lay-event="del" th:onclick="|deleteCourse(${d.id});|">删除</a></td>
				</tr>

			</tbody>
		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
						   <a th:href="|/Major_list?pageIndex=${majorutils.pageIndex-1}&pagesize=${majorutils.pagesize}|" th:if="${majorutils.pageIndex>1}" class="layui-laypage-prev " data-page="0">
							    <i class="layui-icon">&lt;</i>
						   </a> 
<!--							    <span style="color:#009688;font-weight: bold;">1</span> -->
<!--			                       拿到当前显示的页数-->
							    <a th:each="num:${majorutils.numbers}" th:text="${num}" th:style="${majorutils.pageIndex==num}?'color:#009688;font-weight: bold;':''" th:href="|/Major_list?pageIndex=${num}&pagesize=${majorutils.pagesize}|">2</a>
<!--							    <a href="#">3</a>  -->
<!--							    <a href="#">4</a> -->
<!--							    <a href="#">5</a> -->
							<a th:href="|/Major_list?pageIndex=${majorutils.pageIndex+1}&pagesize=${majorutils.pagesize}|" th:if="${majorutils.pageIndex<majorutils.pagecount}" class="layui-laypage-next " data-page="2">
							    <i class="layui-icon">&gt;</i>
							</a> 
							<span class="layui-laypage-skip">到第
							   <input type="text" min="1" value="1" class="layui-input">页
								<button type="button" class="layui-laypage-btn">确定</button>
							</span> 
							<span class="layui-laypage-count">当前[[${majorutils.pageIndex}]]/[[${majorutils.pagecount}]]页/共 [[${majorutils.totalpage}]] 条</span>
							<span class="layui-laypage-limits"> 
							    <select lay-ignore="" onchange="ChangeMajorPagesize(this.value)">
							        <option value="5" th:selected="${majorutils.pagesize==5}">5 条/页</option>
									<option value="10" th:selected="${majorutils.pagesize==10}">10 条/页</option>
									<option value="20" th:selected="${majorutils.pagesize==20}">20 条/页</option>
									<option value="30" th:selected="${majorutils.pagesize==30}">30 条/页</option>

							</select>
							</span>
						</div>
	</div>
	<script src="media/layui/layui.js"></script>
	
	<script type="text/javascript">
	   function deleteCourse(id){
	   	// alert(id)
		   layui.use('table', function() {
			   layer.confirm('是否确认删除学科?',function(index) {
			   	$.getJSON("/Major_delect/"+id,function (result) {
					if (result) {
						layer.msg("删除成功", {icon: 6},function () {
							//刷新
							window.location.reload();
						});
					} else {
						layer.msg("删除失败", {icon: 5});
					}
				})
			   	// $("#tr_"+id)
				   // layer.msg("删除成功", {icon : 6});
				   // layer.msg("删除失败", {icon : 5});
			   });
		   });
	   }
	</script>
	
	
</body>
</html>